/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.saber.certificacao.modelos;

import br.com.saber.certificacao.enums.Papeis;
import br.com.saber.certificacao.modelos.validadores.interfaces.ValidadoInterface;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 *
 * @author gbvbahia
 */
@Entity
@Table(name="roles")
public class Roles implements ValidadoInterface,Comparable<Roles> {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="id", nullable=false, unique=true)
    private Long id;

    @Column(name="descricao",length=200, nullable=false,unique=false)
    private String roleDesc;

    @Enumerated(EnumType.STRING)
    @Column(name="papel_nome",length=30, nullable=false,unique=true)
    private Papeis papel;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getRoleDesc() {
        return roleDesc;
    }

    public void setRoleDesc(String roleDesc) {
        this.roleDesc = roleDesc;
    }

    public Papeis getPapel() {
        return papel;
    }

    public void setPapel(Papeis papel) {
        this.papel = papel;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Roles)) {
            return false;
        }
        Roles other = (Roles) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.saber.certificacao.modelos.Role[id=" + id + "]";
    }

    @Override
    public int compareTo(Roles o) {
        return this.papel.compareTo(o.getPapel());
    }


}
